package com.qianfeng.xinyihezi.xinyihezi.activity.activity_meng;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.activeandroid.Model;
import com.activeandroid.query.Select;
import com.qianfeng.xinyihezi.xinyihezi.R;
import com.qianfeng.xinyihezi.xinyihezi.adapter.adapter_meng.AddressAdapter;
import com.qianfeng.xinyihezi.xinyihezi.model.bean_meng.Address;

import java.util.ArrayList;
import java.util.List;

public class AddressActivity extends AppCompatActivity implements View.OnClickListener {

    private ListView mListView;
    private RelativeLayout mRelativeLayoutEmpty;
    private ImageView mImageView;
    private TextView mTextViewAdd;
    private List<Address> mList;
    private AddressAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_address);
        initView();
        initData();
        setData();
        setListener();
    }

    private void initView() {
        mImageView = (ImageView) findViewById(R.id.iv_address_back);
        mTextViewAdd = (TextView) findViewById(R.id.tv_add_address);
        mRelativeLayoutEmpty = (RelativeLayout) findViewById(R.id.rl_empty_listview);
        mListView = (ListView) findViewById(R.id.lv_address);
    }

    private void initData() {
//        mList = new Select().from(Address.class).execute();
    }

    private void setData() {
        mListView.setEmptyView(mRelativeLayoutEmpty);
//        mAdapter = new AddressAdapter(mList, this);
//        mListView.setAdapter(mAdapter);
    }

    private void setListener() {
        mImageView.setOnClickListener(this);
        mTextViewAdd.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_address_back:
                finish();
                break;
            case R.id.tv_add_address:
                startActivity(new Intent(this, AddAddressActivity.class));
                break;
            default:
                break;
        }
    }
}
